import { useAdminStore } from '@/stores/admin'

export default {
  mounted(el, binding) {
    const { value } = binding
    const adminStore = useAdminStore()
    
    if (adminStore.permissions.includes('*')) return
    // 判断用户是否有该权限
    const hasPermission = adminStore.permissions.includes(value)
    
    // 如果没有权限，则移除该DOM元素
    if (!hasPermission) {
      el.parentNode && el.parentNode.removeChild(el)
    }
  }
}